from base_restful.const import Const, BaseInfo
from base_restful.crm import login_pc, login_app
from base_restful.order import *
from base_restful.erp import *
from base_restful.base_mq import *
import time


def run_activity_order_test():
    BaseInfo.login.change_app()
    # 创建订单
    print('创建订单')
    # 创建商城订单
    result = create_order_pc_activtiy()
    # 创建客服订单那
    # result = create_order()
    orderId = result['data']
    print(result)

    BaseInfo.login.change_pc()

    # 修改支付方式
    print('修改支付方式')
    print(choose_pay_way_zq(orderId))
    time.sleep(4)
    mainBill = erp_query_main_bill_list(orderId)[0]

    print('认领采购单')
    main_bill_id_ = mainBill['mainBillId']
    print(erp_do_claim(main_bill_id_))

    print('采购单分配')
    print(erp_do_distribute(main_bill_id_))

    # 采购确认采购单
    print('采购确认采购单')
    print(erp_do_submit_to_approval(main_bill_id_))

    # 售前取消
    print('售前取消')
    update_result = update_order(orderId)
    print(update_result)

    # 分拣的全部操作
    erp_all_in(orderId)

    # 部分退货
    print('部分退货')
    print(order_return_insert_part(orderId))
    time.sleep(2)

    # 退货审核通过
    print('退货审核通过')
    print(hand_all_return_pass(orderId))

    # # 退货全部入库
    # print(send_all_return_in(orderId))
    # time.sleep(2)
    print('退货全部入库')
    erp_return_hand(orderId)


def erp_all_in(order_id):
    erp_purchase_task_hand_deal(order_id)
    erp_purchase_task_stock_in(order_id)
    erp_purchase_task_stock_out(order_id)


